﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.Finance.Treasuries.Payments;
using System;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;

namespace mozhi.smarterp.Finance.Treasuries
{
    [RemoteService]
    [Route("api/v1/payments")]
    public class PaymentController : BaseController
    {
        private IPaymentAppService _appService;
        public PaymentController(IPaymentAppService appService)
        {
            _appService = appService;
        }


        [HttpGet]
        [Route("{id}")]
        public async Task<PaymentDto> GetAsync(Guid id)
        {
            var result = await _appService.GetAsync(id);

            return result;
        }

        [HttpGet]
        public async Task<PagedResultDto<PaymentDto>> GetAsync(PaymentPagedResultRequestDto filter)
        {
            var result = await _appService.GetListAsync(filter);

            return result;
        }

        [HttpPost]
        public async Task<PaymentDto> CreateAsync(PaymentCreateDto payment)
        {
            var result = await _appService.CreateAsync(payment);

            return result;
        }

        [HttpPut]
        public async Task<PaymentDto> UpdateAsync(PaymentUpdateDto payment)
        {
            var result = await _appService.UpdateAsync(payment);

            return result;
        }

        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _appService.DeleteAsync(id);
        }
    }
}
